<!Doctype html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>登录</title>
	<link rel="stylesheet" type="text/css" href="denglu.css" />
	<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>

	<script src="./js/index.js" type="text/javascript" charset="utf-8"></script>
	<script src="./js/denglu.js" type="text/javascript" charset="utf-8"></script>
	<script src="./js/zhuce.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
	<!--登录注册二选一弹出框-->
	<div id="loginOrRegister">
		<!--标题-->
		<div class="title">
			<span class="login colorRed">登录</span>
			<span class="register">注册</span>
		</div>
		<!--具体信息-->
		<div id="formInformation">
			<!--登录界面-->
			<form method="get" class="loginForm">
				<ul class="box box1">
					<li>
						<label for="account">账号</label>
						<input type="text" placeholder="请输入您的账号（即手机号）" class="account" id="account" />
						<span class="error"></span>
					</li>
					<li>
						<label for="password">密码</label>
						<input type="password" class="password" id="password" placeholder="请输入密码" />
						<span class="error"></span>
					</li>

				</ul>
				<div class="submit">
					<input type="button" value="立即登录" id="ljdl"/>
				</div>
			</form>
			<!--注册界面-->
			<form method="get" class="registerForm">
				<ul class="box box2">
					<li>
						<label for="phone">手机</label>
						<input type="text" placeholder="请输入您的手机号码" id="phone" maxlength="11" />
						<span class="error"></span>
					</li>
					<li>
						<label for="authCode2">用户名</label>
						<input type="text" class=" phonekey" id="authCode2" placeholder="请输入您的用户名" />
						<span class="error"></span>
					</li>
					<li>
						<label for="password2">密码</label>
						<input type="password" class="password" id="password2" placeholder="请输入密码" />
						<span class="error"></span>
					</li>
					<li>
						<label for="password3">确认密码</label>
						<input type="password" class="email" id="password3" placeholder="请再次输入密码" />
						<span class="error"></span>
					</li>
				</ul>
				<div class="submit">
					<input type="button" value="立即注册" class="ljzc"/>
				</div>
			</form>
		</div>
	</div>



	<script>
		
    // // 登录
    $("#ljdl").on("click", function () {
        $.get(
            "http://172.16.107.44:8080/into", 
			{
                "username": $("#account").val(), //账号
                "password": $("#password").val() //密码
            },
            function (data) {
				console.log(data);
				if(data.message=="操作成功！"){
					console.log(data);
					alert("登录成功");
					window.open("./shouye.html");
				}else {
					alert("登陆失败");
				}
            }, 
			"json")
    });

    $(".ljzc").on("click", function () {
        $.get(
            "http://172.16.107.44:8080/add", {
                "phone": $("#phone").val(),
                "password": $("#password2").val(),
                "username": $("#authCode2").val(),
                'name':"大傻逼",
                'email':"145654@qq.com",
        

            },
            function (data) {
				console.log(data);
				if(data.message=="操作成功！"){
					console.log(data);
					alert("注册成功");
					window.open("./shouye.html");
				}else {
					alert("注册失败，请重新注册");
					}
				}, 
			"json")
		
    });


	// $(".ljzc").on("click",function(){
	// 	alert("注册成功")
	// 	window.open("shouye.html");

	// })
	</script>
</body>

</html>